<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<script type="text/javascript" src="<?php echo STATIC_DOMAIN;?>js/highcharts/js/highcharts.src.js"></script>
<script type="text/javascript">
    function ajax_tooltip(val,e,index,status)
    {
        if(status== -1)
        {
            $('#preview-tooltip').hide();
        }
        index-=1;
        var strURL="<?php echo site_url('banner/load_tooltip?bannerid=');?>"+val+"&index="+index;
        var strId= '#tooltip';
        var strId2='#content';
        tooltip_preview (e,strId);
        var success = function(data)
        {
            $(strId2).html(data);
            tooltip_preview (e,strId);
            $('#preview-tooltip').attr('href','<?php echo site_url('../home/editAd')?>/'+val);
            $('#deleted-tooltip').attr('href','<?php echo site_url('../admin/banner/deleteAd')?>/'+val);
        };
        getAjax(strURL,"",'', '', '', false, success);
    }
    
    function ajax_tooltip2(val,e,status)
    {
        var temp = $('#date').val();
    	temp=temp.split(' <?php echo $campaigndetail_lang['to']?> ');
     	var fromdate=temp[0];
     	var todate=temp[1];
     	fromdate=fromdate.split('/');
        fromdate=fromdate[2]+'-'+fromdate[1]+'-'+fromdate[0];
        todate=todate.split('/');
        todate=todate[2]+'-'+todate[1]+'-'+todate[0];
        var strURL="<?php echo site_url('banner/domain_report_tooltip?bannerid=');?>"+val+"&typeid=1&fromdate="+fromdate+"&todate="+todate+"&status="+status;
        var strId= '#tooltip2';
        var strId2='#content2';
        tooltip_preview (e,strId);
        var success = function(data)
        {
            if(data=='error'){
                window.location='<?php echo site_url('banner/error')?>';
            }else if(data=='unlogin'){
                window.location='<?php echo site_url('login')?>';
            }else{
                $(strId2).html(data);
                tooltip_preview (e,strId);
            }
        };
        getAjax(strURL,"",'', '', '', false, success);
    }
</script>
<style>
    #mydiv{
            background-color: white;
            height: 25px;
            width: 260px;
            display:none;
            position:absolute;
            z-index: 9999;
        }
</style>
<div class="ttip-ad-preview" id="tooltip">
    <p class="myclear">
		<img alt="" class="ttip-ad-preview-arrow" src="/images/toannhtooltiparrow.gif" />
	</p>
	<div class="ttip-ad-preview-inner">
		<div class="ttip-ad-preview-inner-pad" id="content">
            <div style="width: 496px;height:273px;text-align: center;">
				<img src="/images/ajax-loader.gif" style="margin-top: 80px;"/>
            </div>
		</div>
		<p class="ttip-adprv-btn-box myclear">
			<a id="preview-tooltip" class="ttip-adprv-edit">
				<?php echo $campaigndetail_lang['editTooltip'];?>
			</a>
			<a id="deleted-tooltip" class="ttip-adprv-edit marleft10" onclick="return confirm('<?php echo $campaigndetail_lang['deleteConfirm'];?>')">
				<?php echo $campaigndetail_lang['temp_deleted'];?>
			</a>
			<a onclick="tooltip_preview_remove('.ttip-ad-preview')" class="ttip-adprv-cancel marleft10">
				<?php echo $campaigndetail_lang['cancelTooltip'];?>
			</a>
		</p>
    </div>
</div>
<div id="exprt-lang-img" class="exprt-lang" >
	<div class="exprt-lang-inner">		
		<table cellpadding="0" cellspacing="0" border="0">
        	<tr>
        		<td class="padtop10">&nbsp;</td>
        		<td class="padtop10" id="tdChkFday">
        			<input type="checkbox" name="chkRunToday" id="chkRunToday" class="ver-middle marright5" onclick="chkRunFromDay(this);" <?php echo ($campaignName[0]['expire']=='31/12/2035')? 'checked="checked"':'';?>/> 
        			<label for="chkRunToday" class="ver-middle">Chiến dịch chạy liên tục</label>
        		</td>
        	</tr>
        	<tr>
        		<td class="ver-middle">
        			<p class="padtop5 padleft3">
        				Ngày bắt đầu									
        			</p>
        		</td>
        		<td class="ver-middle padtop5">
        			<input class="input-date input-date-140" type="text" name="campStartDate" id="campStartDate" readonly="readonly" value="<?php echo $campaignName[0]['activate']?>" <?php echo ($campaignName[0]['expire']=='31/12/2035')? 'disabled="disabled"':'';?>/>
        		</td>
                <td class="ver-middle padtop5">
        			<input type="button" value="OK" id="ok_duration"/>
        		</td>
        	</tr>
        	<tr>
        		<td class="padtop5">
        			<p class="padtop10 padleft3">
        				Ngày kết thúc									
        			</p>
        		</td>
        		<td class="ver-middle padtop10">
        			<input class="input-date input-date-140" type="text" name="campEndDate" id="campEndDate" readonly="readonly" value="<?php echo $campaignName[0]['expire'];?>" <?php echo ($campaignName[0]['expire']=='31/12/2035')? 'disabled="disabled"':'';?>/>
        		</td>
                <td class="ver-middle padtop5">
        			<input type="button" value="Cancel" id="cancel_duration"/>
        		</td>
        	</tr>
            <tr>
                <td colspan="3">
                    <div class="padtop5 padbottom5 text-center error" id="errorCreateCampTime" style="display:none;">
						<?php echo $campaigndetail_lang['create_camp_time_error']?></td>
					</div>
                </td>
            </tr>
        </table>
	</div>
	<p class="myclear">
		<img alt="" id="exprt-img-down" class="exprt-lang-ardown" src="/images/toannhtooltiparrowdown.gif" />
	</p>
</div>
<!--domain tooltip -->
<div class="ttip-ad-preview" id="tooltip2">
    <p class="myclear">
		<img alt="" class="ttip-ad-preview-arrow" src="/images/toannhtooltiparrow.gif" />
	</p>
	<div class="trung-ttip-ad-preview-inner">
		<div class="ttip-ad-preview-inner-pad" id="content2">
            <div style="width: 496px;height:273px;text-align: center;">
				<img src="/images/ajax-loader.gif" style="margin-top: 80px;"/>
            </div>
		</div>
		<p class="ttip-adprv-btn-box myclear">
			<a onclick="tooltip_preview_remove('.ttip-ad-preview')" class="ttip-adprv-edit">
				<?php echo $campaigndetail_lang['cancelTooltip'];?>
			</a>
		</p>
	</div>
</div>
<!-- colum right -->
<div class="middle myclear">
	<div class="pad10">
        <span id="editValueDay" style="display: none;"><?php echo $campaignName[0]['maxValueDay']?></span>
		<div class="col-770">
			
			<!-- bread crumb -->
			<p id="bread-crumb">
				<a href="<?php echo site_url('campaign');?>">
					<?php echo $campaigndetail_lang['AllCampaign'];?>
				</a>
                <span class="ver-middle">
					<?php echo $campaigndetail_lang['campaigndetail'];?>
                </span>
			</p><!-- end bread crumb -->
			
			<table width="100%" class="marbottom10"  border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td width="50%">
						<h2 class="title text-666">
							<span class="text-999"><?php echo $campaigndetail_lang['campaign'];?>: </span> <?php echo $campaignName[0]['campaignname'];?>
						</h2>
					</td>
				</tr>
			</table>
						
			<div class="payment-listbox padbottom10 myclear">
				<div class="mbdetail-info">
					<table  width="100%" cellpadding="0" cellspacing="0" border="0">
						<tr>
							<td >
								<div class="mbd-col-camp">
									<p class="text-999 padbottom5">
                                        <?php echo $campaigndetail_lang['campaignName'];?>
									</p>
									<p>
                                        <span id="editCampaign"><?php echo $campaignName[0]['campaignname']?></span>
										<a id="edittriggerCampaign" style="cursor:pointer" class="mbd-edit"><?php echo $campaigndetail_lang['edit'];?></a>
									</p>
								</div>
							</td>
							
							<td>
								<div class="mbd-col-banner">
									<p class="text-999 padbottom5">
										<?php echo $campaigndetail_lang['status'];?>
									</p>
									
									<p>
										<span id="editStatus">
                                            <?php //echo $campaignName[0]['status'];
                                                if($campaignName[0]['status']==1)
                                                    echo '<img class="cursor-pointer" alt="" src="/images/imgrun.gif" title="'.$campaigndetail_lang['running'].'"/> '.$campaigndetail_lang['running'];
                                                elseif($campaignName[0]['status']==-1)
                                                    echo '<img class="cursor-pointer" alt="" src="/images/imgok.gif" title="'.$campaigndetail_lang['completed'].'"/> '.$campaigndetail_lang['completed'];
                                                elseif($campaignName[0]['status']==5)
                                                    echo '<img class="cursor-pointer" alt="" src="/images/imgpause.gif" title="'.$campaigndetail_lang['paused'].'"/> '.$campaigndetail_lang['paused'];
                                                elseif($campaignName[0]['status']==2)
                                                    echo '<img class="cursor-pointer" alt="" src="/images/temp_deleted.gif" title="'.$campaigndetail_lang['delete'].'"/> '.$campaigndetail_lang['delete'];
                                                elseif($campaignName[0]['status']==4)
                                                    echo '<img class="cursor-pointer" alt="" src="/images/imgout-of-money.png" title="'.$campaigndetail_lang['outofmoney'].'"/> '.$campaigndetail_lang['outofmoney'];
                                                elseif($campaignName[0]['status']==3)
                                                    echo '<img class="cursor-pointer" alt="" src="/images/het_ngan_sach.gif" title="'.$campaigndetail_lang['het_ngan_sach'].'"/> '.$campaigndetail_lang['het_ngan_sach'];
                                                else
                                                    echo $campaignName[0]['status'];
                                            ?>
                                        </span>
                                        <a id="edittriggerStatus" style="cursor:pointer" class="mbd-edit"><?php echo $campaigndetail_lang['edit'];?></a>
									</p>
								</div>
							</td>
							
							<td>
								<div class="mbd-col-status">
									<p class="text-999 padbottom5">
										<?php echo $campaigndetail_lang['budget'];?>
									</p>
									<p>
                                        <div id="mydiv">
                                            <input type="text" value="<?php echo ($campaignName[0]['isperday']==1) ? $campaignName[0]['maxValueDay'] : $campaignName[0]['ExpireValue'] ;?>" id="budgetValue" size="10" style="border:  1px solid #C8C8C8;padding: 5px 5px 5px;" onkeypress='return checkDecimalNumber(event, this);'/>
                                            <select id="budgetSelectType" style="border:  1px solid #C8C8C8;padding: 2px 2px 3px;color: #666666;background: #fff;outline: none;">
                                                <option value="1" <?php echo ($campaignName[0]['isperday']==1) ? 'selected="selected"':'' ;?>><?php echo $campaigndetail_lang['byDate'];?></option>
                                                <option value="0" <?php echo ($campaignName[0]['isperday']==0) ? 'selected="selected"':'' ;?>><?php echo $campaigndetail_lang['byCam'];?></option> 
                                            </select>
                                            <input type="button" value="ok" onclick="campaignUpdateBubget();" style="border:1px solid #C8C8C8;background:  #fff;text-align:  center;padding: 4px 8px 4px;"/>
                                        </div>
                                        <?php if($campaignName[0]['isperday']==1)
                                        {
                                        ?>
                                            <div id="divBudget">
                                                <span id="editBudget"><?php echo number_format($campaignName[0]['maxValueDay'])?>(VND)</span>									
                                                <a style="cursor:pointer;" class="mbd-edit ver-middle" id="edittriggerBudget"><?php echo $campaigndetail_lang['edit'];?></a>
                                                <p class="text-999"><?php echo $campaigndetail_lang['byDate'];?></p>
                                            </div>
                                        <?php
                                        }else{
                                        ?>
                                            <div id="divBudget">
                                                <span id="editBudget"><?php echo number_format($campaignName[0]['ExpireValue'])?>(VND)</span>									
                                                <a style="cursor:pointer;" class="mbd-edit ver-middle" id="edittriggerBudget"><?php echo $campaigndetail_lang['edit'];?></a>
                                                <p class="text-999"><?php echo $campaigndetail_lang['byCam'];?></p>
                                            </div>
                                        <?php
                                        }
                                        ?>
                                    </p>
								</div>
							</td>
							
							<td>
								<div class="mbd-col-target">
                                    <p class="text-999 padbottom5">
										<?php echo $campaigndetail_lang['duration'];?>
									</p>
                                    <p>
                                        <span id="editDuration"><?php echo $campaignName[0]['expire']=='31/12/2035'? 'Chiến dịch chạy liên tục từ ngày '.$campaignName[0]['activate']:$campaignName[0]['activate'].' đến '.$campaignName[0]['expire'];?></span>
										<a id="edittriggerDuration" class="mbd-edit"><?php echo $campaigndetail_lang['edit'];?></a>
									</p>
								</div>
							</td>
                            
                            <td>
								<div class="mbd-col-target">
                                    <p class="text-999 padbottom5">
										<?php echo $campaigndetail_lang['username'];?>
									</p>
                                    <p>
                                        <span><?php echo $userName[0]['username'];?></span>
										<a href="<?php echo site_url('user/edit/'.$userName[0]['user_id']) ;?>" class="mbd-edit"><?php echo $campaigndetail_lang['edit'];?></a>
									</p>
								</div>
							</td>
							<td>
								<div>
                                    <p class="text-999 padbottom5">
										Mã hợp đồng
									</p>
                                    <p>
                                        <span id="editContract"><?php echo $campaignName[0]['contract'];?></span>
                                        <a id="edittriggerContract" class="mbd-edit hide"><?php echo $campaigndetail_lang['edit'];?></a>
									</p>
								</div>
							</td>
							
						</tr>
					</table>
					
									
				</div>
				<table class="mbd-timebox" cellpadding="0" cellspacing="0" border="0">	
					<tr>
						<td class="padright10 ver-middle">
							<input class="input-time" type="text" id="date" value="<?php echo date('d/m/Y',strtotime($fromdate))?> <?php echo $campaigndetail_lang['to'];?> <?php echo date('d/m/Y',strtotime($todate))?>" />
						</td>

                        <td class="ver-middle">
                            <img id="loading1" src="/images/ajaxLoading.gif" class="martop5 ver-middle" style="display: none;"/>
                        </td>
					</tr>
				</table>
				<div id="campaigndiv">
				<table class="martop5 tbl-list" width="100%" cellpadding="0" cellspacing="0" border="0" id="table">
                <thead>
					<tr>
						<th class="td-label bold text-center">
							<p class="ver-middle" style="height:33px;line-height: 33px;"><?php echo $campaigndetail_lang['#'];?></p>
						</th>
						
						<th class="td-label bold text-center">
							<span class="ver-middle" style="height:33px;line-height: 33px;"><?php echo $campaigndetail_lang['preview'];?></span>
						</th>
						
						<th class="td-label bold text-center">
							<p class="ver-middle" style="height:33px;line-height: 33px;"><?php echo $campaigndetail_lang['ad'];?></p>
						</th>
						
						<th class="td-label bold text-center" colspan="2">
							<p class="ver-middle" style="height:33px;line-height: 33px;"><?php echo $campaigndetail_lang['status'];?></p>
						</th>
						
						<th class="td-label bold text-center {sorter: 'fancyNumber'}">
							<p class="ver-middle" style="height:33px;line-height: 33px;">Click</p>
						</th>
						
						<th class="td-label bold text-center {sorter: 'fancyNumber'}">
							<p class="ver-middle" style="height:33px;line-height: 33px;">Impressions</p>
						</th>
						
						<th class="td-label bold text-center {sorter: 'fancyNumber'}">
							<p class="ver-middle" style="height:33px;line-height: 33px;">Unique Visitor</p>
						</th>
												
						<th class="td-label bold text-center">
							<p class="ver-middle" style="height:33px;line-height: 33px;"><b>CTR</b> %</p>
						</th>
						
						<th class="td-label text-center {sorter: 'fancyNumber'}">
							<p class="ver-middle" style="height:33px;line-height: 33px;"><b><?php echo $campaigndetail_lang['spent'];?></b>(VND)</p>
						</th>
					</tr>
                </thead>
                <tbody>
					<?php $index=1;
                    $totalspent=0;
                    foreach($info as $if)
                    {
                    ?>
					<tr>
						<td class="ver-middle">
							<p class="camp-dt-cl-stt">
								<?php echo $index;?>
							</p>
						</td>
						
						<td class="ver-middle">
							<p class="camp-dt-cl-img">
                                <a onclick="ajax_tooltip(<?php echo $if['bannerid']?>,this,<?php echo $index;?>,<?php echo $if['status'];?>);">
								    <img class="block marcenter" alt="" src="<?php echo $if['filepath'];?>" width="50" height="50"/>
                                </a>
							</p>
						</td>
						
						<td class="ver-middle">
							<p class="camp-dt-cl-banner">
                                <a href="<?php echo site_url('bannerdetail/index?bannerid='.$if['bannerid'].'&fromdate='.$fromdate.'&todate='.$todate);?>">
								    <?php echo $if['bannername'];?>
                                </a>
							</p>
						</td>
						
						<td class="ver-middle">
							<p class="camp-dt-cl-status edit text-center" style="width: 25px;">
                                <input type="hidden" value="<?php echo site_url('campaigndetail/edit?bannerid='.$if['bannerid'].'&type=1');?>" class="hddEditLink"/>
				    				<?php
				        			if(isset($if['outofstore']) && $if['outofstore']==1)
				                    {
				                        echo '<img class="cursor-pointer marright5 ver-middle" alt="" src="/images/dealed.png" title="'.$campaigndetail_lang['dealed'].'"/>';
				                    	
				                        if($if['status']==-1){
					                        $oldStatus = '<img class="cursor-pointer ver-middle" alt="" src="/images/imgok.gif" title="'.$campaigndetail_lang['completed'].'"/>';
					                    }
					                    elseif($if['status']==0){
					                        $oldStatus = '<img class="cursor-pointer ver-middle" alt="" src="/images/temp_deleted.gif" title="'.$campaigndetail_lang['temp_deleted'].'"/>';
					        			}
					                    elseif($if['status']==1){
					                        $oldStatus = '<img class="cursor-pointer ver-middle" alt="" src="/images/imgrun.gif" title="'.$campaigndetail_lang['running'].'"/>';
					                    }
					                    elseif($if['status']==2){
					                        $oldStatus = '<img class="cursor-pointer ver-middle" alt="" src="/images/imgpause.gif" title="'.$campaigndetail_lang['paused'].'"/>';
					                    }
					                    elseif($if['status']==3){
					                        $oldStatus = '<img class="cursor-pointer ver-middle" alt="" src="/images/imgwait.png" title="'.$campaigndetail_lang['waiting'].'"/>';
					                    }
					                    elseif($if['status']==4){
					                        $oldStatus = '<img class="cursor-pointer ver-middle" alt="" src="/images/imgproblem.png" title="'.htmlentities($if['error'],ENT_QUOTES,"UTF-8").'"/>';
					                    }
					                    elseif($if['status']==5){
					                        $oldStatus = '<img class="cursor-pointer ver-middle" alt="" src="/images/imgout-of-money.png" title="'.$campaigndetail_lang['outofmoney'].'"/>';
					                    }
					                    elseif($if['status']==6){
					                       	$oldStatus = '<img class="cursor-pointer ver-middle" alt="" src="/images/het_ngan_sach.gif" title="'.$campaigndetail_lang['het_ngan_sach'].'"/>';
					                    }
					                    elseif($if['status']==8){
					                        $oldStatus = '<img class="cursor-pointer ver-middle" alt="" src="/images/chochay.gif" title="'.$campaigndetail_lang['waittorun'].'"/>';
					                    }
					                    else{
					                        $oldStatus = $if['status'];}
				                    }
				    				else
				    				{
					                    if($if['status2']==1){
					                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/low-ctr.png" title="'.$campaigndetail_lang['ctrlow'].'"/>';
					                    }
					                    elseif($if['status2']==2){
					                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/khongdutien.png" title="'.$campaigndetail_lang['cam_not_money_tt'].'"/>';
					                    }
					                    elseif($if['status2']==3){
					                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/api.png" title="'.$campaigndetail_lang['api_mc_copy_3'].'"/>';
					                    }
					    				elseif($if['status2']==4){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/api.png" title="'.$campaigndetail_lang['api_mc_update_4'].'"/>';
						                    }
					    				elseif($if['status2']==5){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/api.png" title="'.$campaigndetail_lang['api_mc_copy_5'].'"/>';
						                    }
					    				elseif($if['status2']==6){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/api.png" title="'.$campaigndetail_lang['api_mc_update_6'].'"/>';
						                    }
					    				elseif($if['status2']==7){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/low-ctr.png" title="'.$campaigndetail_lang['api_mc_weekly_7'].'"/>';
						                    }
					    				elseif($if['status2']==8){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/api.png" title="'.$campaigndetail_lang['api_mc_service_8'].'"/>';
						                    }
					                    else{
					                        //
					                    }
				    				}
				                    ?>
							</p>
						</td>
						
						<td class="ver-middle">
							<input type="hidden" value="<?php echo site_url('campaigndetail/edit?bannerid='.$if['bannerid'].'&type=1');?>" class="hddEditLink"/>
							<p class="camp-dt-cl-status edit text-center 
										<?php 
			                                if((isset($if['outofstore']) && $if['outofstore']==1)||($if['status']==2)||($if['status']==8))
			                                {echo 'edit2';}
			                                elseif(($if['status']== 1)||($if['status']==5))
			                                {echo 'edit1';}
			                                elseif($if['status']==0)
			                                {echo 'edit3';}
			                                else
			                                {echo 'edit';}
		                                ?>" style="width: 22px;">
					                    <input type="hidden" value="<?php echo site_url('banner/edit') . '?bannerid='. $if['bannerid'].'&type=1';?>" class="hddEditLink"/>
		                                <?php //echo $if['status'];
					        			if(isset($if['outofstore']) && $if['outofstore']==1){
					    					echo $oldStatus;
					    				}
					                    else
					                    {
						                    if($if['status']==-1){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/imgok.gif" title="'.$campaigndetail_lang['completed'].'"/>';
						                    }
						                    elseif($if['status']==0){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/temp_deleted.gif" title="'.$campaigndetail_lang['temp_deleted'].'"/>';
						        			}
						                    elseif($if['status']==1){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/imgrun.gif" title="'.$campaigndetail_lang['running'].'"/>';
						                    }
						                    elseif($if['status']==2){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/imgpause.gif" title="'.$campaigndetail_lang['paused'].'"/>';
						                    }
						                    elseif($if['status']==3){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/imgwait.png" title="'.$campaigndetail_lang['waiting'].'"/>';
						                    }
						                    elseif($if['status']==4){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/imgproblem.png" title="'.htmlentities($if['error'],ENT_QUOTES,"UTF-8").'"/>';
						                    }
						                    elseif($if['status']==5){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/imgout-of-money.png" title="'.$campaigndetail_lang['outofmoney'].'"/>';
						                    }
						                    elseif($if['status']==6){
						                       	echo '<img class="cursor-pointer ver-middle" alt="" src="/images/het_ngan_sach.gif" title="'.$campaigndetail_lang['het_ngan_sach'].'"/>';
						                    }
						                    elseif($if['status']==8){
						                        echo '<img class="cursor-pointer ver-middle" alt="" src="/images/chochay.gif" title="'.$campaigndetail_lang['waittorun'].'"/>';
						                    }
						                    else{
						                        echo $if['status'];}
					                     }
				                    ?>
							</p>
						</td>
                        
						<td class="ver-middle">
							<p class="camp-dt-cl-click">
								<a <?php echo (($if['clicks']!= 'N/A')&&($if['clicks']!= 0)) ? 'onclick="ajax_tooltip2('.$if['bannerid'].',this,'.$if['status'].')"' : '' ;?> ><?php echo $if['clicks'];?></a>
							</p>
						</td>
						
						<td class="ver-middle">
							<p class="camp-dt-cl-imp">
								<a <?php echo (($if['impressions']!= 'N/A')&&($if['impressions']!= 0)) ? 'onclick="ajax_tooltip2('.$if['bannerid'].',this,'.$if['status'].')"' : '' ;?> ><?php echo $if['impressions'];?></a>
							</p>
						</td>
						
						<td class="ver-middle">
							<p class="camp-dt-cl-uv">
								<?php echo $if['uviews'];?>
							</p>
						</td>
						
						<td class="ver-middle">
							<p class="camp-dt-cl-ctr">
								<?php echo $if['CTR'];?>
							</p>
						</td>
						
						<td class="ver-middle">
							<p class="camp-dt-cl-money">
								<?php echo (($if['money']!= 'N/A')&&($if['money']!= 0)) ? number_format($if['money']) : 'N/A' ;?>
							</p>
						</td>
					</tr>
					<?php
                    $index++;
                    }
					?>
                    </tbody>
					<!-- row total -->
					<tr>
						<td colspan="4">
							<p class="camp-dt-cl-total bold">
								<?php echo $campaigndetail_lang['total'];?>
							</p>
						</td>
						<td>
							<p class="camp-dt-cl-click bold">
								<?php echo $total[0]['clicks'];?>
							</p>
						</td>
						
						<td>
							<p class="camp-dt-cl-imp bold">
								<?php echo $total[0]['impressions'];?>
							</p>
						</td>
						
						<td>
							<p class="camp-dt-cl-uv bold">
								<?php echo $total[0]['uviews'];?>
							</p>
						</td>
						
						<td>
							<p class="camp-dt-cl-ctr bold">
								<?php echo $total[0]['CTR'];?>
							</p>
						</td>
						
						<td>
							<p class="camp-dt-cl-money bold">
							<?php echo $total[0]['money'];?>
							</p>
						</td>
					</tr>
					<!-- end row total -->
				
				</table>
				
				<table class="tbl-list brv-paging martop10 float-right" border="1" cellpadding="0" cellspacing="0">
					<tr>
						<td class="brv-paging-name">
							<?php echo $campaigndetail_lang['page'];?> <?php echo $page; ?>/<?php echo $totalpage; ?>
						</td>
						
						<td class="brv-paging-pre-next" width="48">
							<img class="brv-img-pre" alt="previous" src="/images/imgpre.gif" <?php echo ($page > 1) ? 'onclick="campPaging(\'' . site_url("campaigndetail/index?campaignid=$campaignid&fromdate=$fromdate&todate=$todate&page=".($page-1)."&rownum=".$rownum).'\');"' : ''; ?>/>
							<img class="brv-img-next" alt="next" src="/images/imgnext.gif" <?php echo ($page < $totalpage) ? 'onclick="campPaging(\'' . site_url("campaigndetail/index?campaignid=$campaignid&fromdate=$fromdate&todate=$todate&page=".($page+1)."&rownum=".$rownum).'\');"' : ''; ?> />
						</td>
						
						<td class="brv-paging-num-item">
							<select id="slcNumItem" onchange="campPaging('<?php echo site_url("campaigndetail/index?campaignid=$campaignid&fromdate=$fromdate&todate=$todate&page=1&rownum="); ?>' + this.value);">
								<option value="10" <?php echo ($rownum == 10) ? 'selected="selected"' : '';?> >10</option>
								<option value="20" <?php echo ($rownum == 20) ? 'selected="selected"' : '';?> >20</option>
								<option value="50" <?php echo ($rownum == 50) ? 'selected="selected"' : '';?>>50</option>
							</select>
						</td>
					</tr>
				</table>
                <table cellpadding="0" cellspacing="0" border="0" class="padtop20 padbottom20">
                    <tr>
                        <td>
                            <a href="javascript:void(0);" class="graybtn marright5">
    							<span class="curr" onclick="ajax_chart(0);" id="clicks">Clicks</span>
    						</a>
                        </td>
                        <td>
                            <a href="javascript:void(0);" class="graybtn marright5">
    							<span onclick="ajax_chart(1);" id="impressions">Impressions</span>
    						</a>
                        </td>
                        <?php if(count($lstBanner)>0){ ?>
                        <td>
                            <p class="marright5">
                                <select multiple="multiple" id="selector" name="selector[]" multiple="multiple" size="5">
                                    <?php foreach ($lstBanner as $lBanner) { ?>
                                        <option value="<?php echo $lBanner['bannerid'] ?>"><?php echo $lBanner['bannername'] ?></option>      
                                    <?php } ?>
                                </select>
                            </p>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="graybtn">
    							<span id="ren">OK</span>
    						</a>
                        </td>
                        <?php }?>
                        <td>
                            <a class="marleft10">
    							<img id="loading" src="/images/ajaxLoading.gif" class="martop5 ver-middle" style="display: none;"/>
    						</a>
                        </td>
                    </tr>
                </table>
                <div id="my_chart"></div>
				</div>
				<br /><br /><br /><br />
			</div>
			
			
			
		</div> <!-- end colum right -->
		
		<!-- important. fix for ie 6. Don't remove -->
		<!--[if IE 6]><br class="clearboth" /><![endif]-->
	</div> <!-- end page content -->
 </div>
<script type="text/javascript">
    function campPaging(url)
	{
		window.location = url;
		return;
	}
    function ajax_chart(val)
    {
        var temp =$('#date').val();
        var arrTime = temp.toString().split(' <?php echo $campaigndetail_lang['to']?> ');
        var fromdate = arrTime[0];
        var todate = arrTime[1];
        var strReplace="/";
        arrFromdate=fromdate.toString().split('/');
        fromdate=arrFromdate[2]+'-'+arrFromdate[1]+'-'+arrFromdate[0];
        arrTodate=todate.toString().split('/');
        todate=arrTodate[2]+'-'+arrTodate[1]+'-'+arrTodate[0];
        var about = [];
        $("input[name='selector[]']:checked").each(function(){about.push($(this).val());});
        lstBanner = about.join(",");
        var onSuccess= function(data) 
        {
            if(data=='error'){
                window.location='<?php echo site_url('banner/error')?>';
            }else if(data=='unlogin'){
                window.location='<?php echo site_url('login')?>';
            }else{
                if(val==0)
                {
                    $('#impressions').removeClass("curr");
                    $('#clicks').addClass("curr");
                }else{
                    $('#clicks').removeClass("curr");
                    $('#impressions').addClass("curr");
                }
                $('#my_chart').html(data);
                $('#loading').hide();
            }
        };
        $('#loading').show();
        var strURL="<?php echo site_url('campaigndetail/ajax_chart?campaignid='.$campaignid.'&fromdate=');?>"+fromdate+"&todate="+todate+"&type="+val+"&lstBanner="+lstBanner;
        getAjax(strURL,"",'', '', '', false, onSuccess);
    }
    function ajax_tooltip2(val,e,status)
    {
        var strId= '#tooltip2';
        var strId2='#content2';
		$(strId2).html('content');
		tooltip_preview (e,strId);
    }
    $('#edittriggerDuration').click(function() 
    {
        var pos = $(this).offset();
		var tleft = pos.left;
		var explH = $('#exprt-lang-img').outerHeight();
		var ttop = pos.top - explH;
		$('#exprt-lang-img').css("top",ttop + "px");
		$('#exprt-lang-img').css("left",tleft + "px");
		$('#exprt-lang-img').fadeIn(300);
    });
    $("#cancel_duration").click(function()
    {
        $('#exprt-lang-img').fadeOut(300);
        $('#errorCreateCampTime').fadeOut(300);
		return false
	});

    $("#ok_duration").click(function()
    {
        var fromDate = $('#campStartDate').val();
        if($('#chkRunToday').attr('checked'))
    	{
            var toDate = '31/12/2035';
        }
    	else
    	{
    		var toDate = $('#campEndDate').val();
    	}
        arrFromDateComp=fromDate.split('/');
        fromDate =arrFromDateComp[2] + '-' + arrFromDateComp[1] + '-' + arrFromDateComp[0];
        arrToDateComp=toDate.split('/');
        toDate =arrToDateComp[2] + '-' + arrToDateComp[1] + '-' + arrToDateComp[0];
		var strURL="<?php echo site_url('campaigndetail/editDuration?campaignid='.$campaignName[0]['campaignid']);?>&fromdate="+fromDate+"&todate="+toDate;
        var success = function(data)
        {
            if(data=='error'){
                window.location='<?php echo site_url('banner/error');?>';
            }else if(data=='unlogin'){
                window.location='<?php echo site_url('login');?>';
            }else{
                $('#editDuration').html(data);
                $('#exprt-lang-img').fadeOut(300);
                $('#errorCreateCampTime').fadeOut(300);
            }
        };
        getAjax(strURL,"",'', '', '', false, success);
	});

    $('#date').DatePicker({
        format: 'd/m/Y',
        date: ['<?php echo date('d/m/Y',strtotime($fromdate));?>','<?php echo date('d/m/Y',strtotime($todate));?>'],
        current: '<?php echo date('d/m/Y');?>',
        calendars: 2,
        mode: 'range',
        starts: 1, 
        notDisable: true,
        onChange: function(formated, dates) 
        {
            $('#loading1').show();
            $('#date').val(formated.join(' <?php echo $campaigndetail_lang['to'];?> '));
            $('#date').DatePickerHide();
            var arrTime = formated.toString().split(',');
            var fromdate = arrTime[0];
            var todate = arrTime[1];
            var strReplace="/";
            arrFromdate=fromdate.toString().split('/');
            fromdate=arrFromdate[2]+'-'+arrFromdate[1]+'-'+arrFromdate[0];
            arrTodate=todate.toString().split('/');
            todate=arrTodate[2]+'-'+arrTodate[1]+'-'+arrTodate[0];
            var type = ($('#clicks').attr('class')=='curr') ? 0:1;
            var about = [];
            $("input[name='selector[]']:checked").each(function(){about.push($(this).val());});
            lstbanner = about.join(",");
                
            var strURL="<?php echo site_url('campaigndetail/index?campaignid='.$campaignid.'&fromdate=');?>"+fromdate+"&todate="+todate;
            window.location=strURL;
        }
    });
    
    $("#ren").click( function() 
    {   
        var about = [];
        $("input[name='selector[]']:checked").each(function(){about.push($(this).val());});
        lstBanner = about.join(",");
        var temp =$('#date').val();
        var arrTime = temp.toString().split(' <?php echo $campaigndetail_lang['to']?> ');
        var fromdate = arrTime[0];
        var todate = arrTime[1];
        var strReplace="/";
        arrFromdate=fromdate.toString().split('/');
        fromdate=arrFromdate[2]+'-'+arrFromdate[1]+'-'+arrFromdate[0];
        arrTodate=todate.toString().split('/');
        todate=arrTodate[2]+'-'+arrTodate[1]+'-'+arrTodate[0];
        
        var val = ($('#clicks').attr('class')=='curr') ? 0:1;
        var strURL="<?php echo site_url('campaigndetail/ajax_chart?campaignid='.$campaignid.'&fromdate=');?>"+fromdate+"&todate="+todate+"&type="+val+"&lstBanner="+lstBanner;
        var onSuccess= function(data) 
        {
            if(data=='error'){
                window.location='<?php echo site_url('banner/error')?>';
            }else if(data=='unlogin'){
                window.location='<?php echo site_url('login')?>';
            }else{
                if(val==0)
                {
                    $('#impressions').removeClass("curr");
                    $('#clicks').addClass("curr");
                }else{
                    $('#clicks').removeClass("curr");
                    $('#impressions').addClass("curr");
                }
                $('#my_chart').html(data);
                $('#loading').hide();
            }
        };
        $('#loading').show();
        getAjax(strURL,"",'', '', '', false, onSuccess);
        return false;
    });

    function isCheckedById(id) 
    { 
        var checked = $("input[@id="+id+"]:checked").length; 
        if (checked == 0) 
        { 
            return false; 
        } 
        else 
        { 
            return true; 
        } 
    }
        
    function isMaxCheckedById(id) 
    { 
        var checked = $("input[@id="+id+"]:checked").length; 
        if (checked >= 3) 
        { 
            return false; 
        } 
        else 
        { 
            return true; 
        } 
    }
    
    $(document).ready(function() 
    {
        $("#selector").multiSelect(
        {
    	     selectAll: false,
             noneSelected: 'Xin chọn quảng cáo!',
             oneOrMoreSelected :'% quảng cáo được chọn.',
             warningMsg:'Bạn không được chọn quá 3 chiến dịch' 
        });
        $("#frm").submit( function() {
			if (!isCheckedById("selector")) 
            { 
                alert ("Bạn chưa chọn quảng cáo nào"); 
                return false; 
            } 
		});
        
        //sorter,pager
        jQuery.tablesorter.addParser({
          id: "fancyNumber",
          is: function(s) {
            return false;
          },
          format: function(s) {
            return parseFloat( s.replace(/,/g,'') );
          },
          type: "numeric"
        });
        <?php if(count($info)>0)
        {
        ?>
        $('#table').tablesorter({headers: 
            { 
            4: {sorter:'fancyNumber'},
            5: {sorter:'fancyNumber'},
            6: {sorter:'fancyNumber'},
            8: {sorter:'fancyNumber'}
            }
        });
        <?php
        }
        ?>
    }); 

    $('#editStatus').editable('editCampaign?campaignid=<?php echo $campaignid?>&type=1', 
    {  
        data   : "{'1':'<?php echo $campaigndetail_lang['run'];?>','5':'<?php echo $campaigndetail_lang['paused'];?>','3':'<?php echo $campaigndetail_lang['completed'];?>', 'selected':'1'}",
        type:"select",
        event : 'status_click',
        submit : 'OK',
        indicator : 'Wait...',
        id : 'hk',
        name : 'ns',
        css : 'inherit',
        cssclass : "editable",
        onblur    : "cancel",
        callback: function(value, settings) { 
            $('#edittriggerStatus').show();
        },
        "onreset": function() {
            $('#edittriggerStatus').show();
        }
    });
    $('#edittriggerStatus').bind('click', function() {
          $(this).prev().trigger('status_click');
          $('#edittriggerStatus').hide();
    });
    $('#editContract').editable('editCampaign?campaignid=<?php echo $campaignid?>&type=6',
            {
                event : 'contract_click',
                submit : 'OK',
                indicator : 'Wait...',
                id : 'hk',
                name : 'ns',
                css : 'inherit',
                onblur    : "cancel",
                cssclass : "editable1",
                callback: function(value, settings) {
                    if(value=='error')
                    {
                        window.location = '<?php echo site_url('campaigndetail/error');?>';
                    }else if(value=='unlogin'){
                        window.location = '<?php echo site_url('campaigndetail/error');?>';
                    }else{
                        $('#edittriggerContract').show();
                    }
                },
                "onsubmit":function(settings, td) {
                    var input = $(td).find('input');
                    var original = input.val();
                    if (original=="") {
                        //alert("");
                        return false;
                    }else {
                        return true;
                    }
                },
                "onreset": function() {
                    $('#edittriggerContract').show();
                }
            });
        $('#edittriggerContract').bind('click', function() {
            $(this).prev().trigger('contract_click');
            $('#edittriggerContract').hide();
      	});
    $('#editCampaign').editable('editCampaign?campaignid=<?php echo $campaignid?>&type=0', 
    {  
            event : 'campaign_click',
            submit : 'OK',
            indicator : 'Wait...',
            id : 'hk',
            name : 'ns',
            css : 'inherit',
            onblur    : "cancel",
            cssclass : "editable",
            callback: function(value, settings) { 
                $('#edittriggerCampaign').show();
            },
            "onreset": function() {
                $('#edittriggerCampaign').show();
            }
        });
        $('#edittriggerCampaign').bind('click', function() {
              $(this).prev().trigger('campaign_click');
              $('#edittriggerCampaign').hide();
    });

    function checkDecimalNumber(evt, o)
    {
        var l = o.value.length;
        var charCode = (evt.which) ? evt.which : event.keyCode ;
        if(l<=0)
        {
            if(charCode==48)
            {
                return false;
            }
        }
        if ( charCode > 31 && ((charCode < 48 && charCode != 46) || charCode > 57) ) 
        {
            return false;
        }else{
            var v = o.value;
            if(charCode == 46)
            {
                var i = v.indexOf('.');
                if(i != -1)
                {
                    return false;
                }else{
                    return true;
                }
            }else{
                return true;
            }
        }
    }
      
    document.onclick=check;
    function check(e)
    {
        var target = (e && e.target) || (event && event.srcElement);
        var obj = document.getElementById('mydiv');
        var obj2 = document.getElementById('edittriggerBudget');
        checkParent(target)?obj.style.display='none':null;
        target==obj2?obj.style.display='block':null;
    }
    
    function checkParent(t)
    {
        while(t.parentNode)
        {
            if(t==document.getElementById('mydiv'))
            {
                return false
            }
            t=t.parentNode
        }
        return true
    }
    
    $('#edittriggerBudget').bind('click', function() {
            $("#divBudget").trigger('click');
    });

    function campaignUpdateBubget()
    {
        var arrTime = $('#editDuration').html();
        <?php if($campaignName[0]['expire']=='31/12/2035'){ ?>  
            arrTime = arrTime.split("<?php echo $campaigndetail_lang['ctnCampaign'];?>");
            var fromdate = arrTime[1];
            var todate = '31/12/2035';
        <?php }else{?>
            arrTime = arrTime.split(" <?php echo $campaigndetail_lang['to'];?> ");
            var fromdate = arrTime[0];
            var todate = arrTime[1];
        <?php }?>
        fromdate=fromdate.replace(/\//g,'-');
        todate=todate.replace(/\//g,'-');
        var val = $('#budgetValue').val();
        var byType = $('#budgetSelectType').val();
        var strURL="<?php echo site_url('campaigndetail/editBudget?campaignid='.$campaignid);?>&type=2&value="+val+"&byType="+byType+"&fromdate="+fromdate+"&todate="+todate;
        var success = function(data)
        {
        	$('#divBudget').html(data);
        	$('#mydiv').hide();
        };
        getAjax(strURL,"",'', '', '', false, success);
    }
    <?php if(count($info)>0){ ?>
    $(function() 
    {        
        $(".edit").editable('',
        { 
		    data   : "{'1':'<?php echo $campaigndetail_lang['run'];?>','2':'<?php echo $campaigndetail_lang['paused'];?>','3':'<?php echo $campaigndetail_lang['temp_deleted'];?>','selected':'<?php echo $if['status']?>'}",
		    type:"select",
		    submit : 'OK',
		    indicator : 'Wait...',
		    id : 'hk',
		    name : 'ns',
            typeEdit:true,
		    css : 'inherit',
		    cssclass : "editable",
		    onblur    : "cancel"
        });  
    });
    <?php }?>
    $('input#campStartDate').DatePicker({
			format: 'd/m/Y',
			date: '<?php echo date('d/m/Y'); ?>',
			position: 'right',	
			notDisable: true,
			onChange: function(formated, dates)
            {
				
				var currTime = new Date();
				var currYear = currTime.getFullYear();
				var currMonth = currTime.getMonth();
				currMonth = parseInt(currMonth) < 10 ? '0' + (currMonth + 1) : (currMonth + 1);
				var currDay = currTime.getDate();
				var currToday = new Date(currYear + '/' + currMonth + '/' + currDay);
				var arr = formated.split('/');
				var startDate = new Date(arr[2] + '/' + arr[1] + '/' + arr[0]);
				if(startDate < currToday)
				{
					showDivCreateCampTimeErr(true);
					return;
				}
				else
				{
					showDivCreateCampTimeErr(false);
					$('#campStartDate').val(formated);
					$('#startDate').val(formated);
					$('#review_camp_start').html(formated);
					$('input#campStartDate').DatePickerHide();
					
					var arrEndDate = $('#campEndDate').val().split('-');
					var endDate = new Date(arrEndDate[2] + '/' + arrEndDate[1] + '/' + arrEndDate[0]);
					
					var numSlcDay = ((endDate - startDate)/86400000) + 1;
					$('#review_num_camp_day').html(numSlcDay);
				}
			}
		});
		$('input#campEndDate').DatePicker({
            
			format: 'd/m/Y',
			date: '<?php echo date('d/m/Y'); ?>',
			position: 'right',
			notDisable: true,
			onChange: function(formated, dates){
				var arr = formated.split('/');
				var slcDate = new Date(arr[2] + '/' + arr[1] + '/' + arr[0]);
				var arrStartDate = $('#campStartDate').val().split('-');
				var startDate = new Date(arrStartDate[2] + '/' + arrStartDate[1] + '/' + arrStartDate[0]);
				
				var currTime = new Date();
				var currYear = currTime.getFullYear();
				var currMonth = currTime.getMonth();
				currMonth = parseInt(currMonth) < 10 ? '0' +(currMonth + 1) : (currMonth + 1);
				var currDay = currTime.getDate();
				var today = new Date(currYear + '/' + currMonth + '/' + currDay);
				
				
				if(slcDate < startDate)
				{
					showDivCreateCampTimeErr(true);
					return;
				}
				else if(slcDate < today)
				{
					showDivCreateCampTimeErr(true);
					return;
				}
				else
				{
					showDivCreateCampTimeErr(false);
					$('#campEndDate').val(formated);
					$('#endDate').val(formated);
					$('#review_camp_end').html(formated);
					$('input#campEndDate').DatePickerHide();
					
					var numSlcDay = ((slcDate - startDate)/86400000) + 1;
					$('#review_num_camp_day').html(numSlcDay);
				}
			}
		});
    $(".datepicker").css("z-index","100000000000");
    ajax_chart(0);
</script>